Repository navigation
[PR] fix(log-mask): scrub JSON-quoted credentials and Groq/Hugging Face keys - #5939
ranxianglei merged 2 commits into
Conversation
redactSecretsInText runs on every log line and, through redactForPublish,
on the diagnostics blob that users paste into public GitHub issues. Its
key=value rule required ":" or "=" right after the key name, so the
JSON/dict shape that upstream error bodies and config dumps use -
"api_key": "...", "password": "...", 'access_token': '...' - passed
through verbatim unless the value happened to start with a known prefix
such as sk-. The existing JSON test case only passed for that reason.
Allow an optional quote between the key name and the separator, and mask
gsk_ (Groq) and hf_ (Hugging Face) keys like sk- ones; both providers are
on PUBLIC_HOST_SUFFIXES. Usage-count keys ("prompt_tokens", "tokens",
"max_tokens") and short values stay verbatim, and a second pass over
redacted text is still a no-op.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014TonJ1geSd97oAtSBZofUK
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Duplicate screening: not a duplicate. No open issue/PR covers this exact gap (JSON-quoted key separator + missing What I verified (not taken on faith):
Behavior change (old → new, intended): previously JSON/dict-shaped credentials whose value lacked a known prefix leaked through logs and the public-issue diagnostics blob; now masked. Two new key prefixes ( Live CI state (just checked): still running — 30 checks, 0 failed, 9 in progress (windows-22 shards 1&2 and static-gates/ubuntu-24 already green). I am not claiming full-green yet. Process note (non-blocking): no source issue is referenced — this is a self-discovered standalone fix, which is fine for an external contribution. Suggested labels for triage: 结构化八问(供人审):
判定:外部贡献者质量达标——双向断言齐备(符合 gate 纪律)、diff 收敛(3 文件,无跑题/空白噪音)、注释讲 why、测试在 master 上确红/head 上确绿。无需对齐重构。待 CI 全绿即可合入(合并权在人)。 |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) CI update: now fully complete — 18 passed, 12 skipped (matrix cells gated off by design for this 3-file change), 0 failed. The last open condition in my review (full-green) is met. Verdict unchanged and now unblocked: clean external contribution, no refactor needed → ready to merge (merge stays human-only). Nothing further from me unless you want the |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.1089-master.fdb30f8 # this exact build
npm install -g billion-context@master # always the newest merged build
|
Problem
redactSecretsInTextruns on every log line (src/logger.ts). ThroughredactForPublish, it also runs on the diagnostics blob that users paste into public GitHub issues (src/web/diagnostics.ts).Its
key=valuerule requires:or=immediately after the key name. In the JSON/dict shape that upstream error bodies and config dumps use, a closing quote comes first, so the rule never matches. These all passed through verbatim on currentmaster:The existing JSON test case (
"api_key":"sk-secret-value-12") only passes because its value starts withsk-, which the separate key-prefix rule catches. A JSON-quoted key whose value has no known prefix was never masked.Groq (
gsk_…) and Hugging Face (hf_…) keys are also not covered by any prefix rule, although both providers are onPUBLIC_HOST_SUFFIXES.Change (
src/log-mask.ts)\b["']?\s*[:=]. The captured prefix keeps the quote, so the output is"api_key":"<masked 20 chars>".gsk_andhf_keys the same way assk-:(?<![A-Za-z0-9])(?:gsk|hf)_[A-Za-z0-9]{20,}.Kept verbatim: usage-count keys (
"prompt_tokens":1234,"tokens": 1234,"max_tokens":4096), short values ("token":"abc"), and identifiers such ashf_hub_download. A second pass over redacted text is still a no-op.Tests
tests/log-mask.test.ts: the leaking shapes above, the negatives, and idempotency.tscor lint. I verified the change by loadingsrc/log-mask.tsdirectly with Node's built-in type stripping. The module imports onlynode:cryptoandnode:os. Results:redactSecretsInTexttest, including its negatives, passes unchanged.masterand pass with this change.CHANGELOG.md: entry added under[Unreleased] → Fixed.